import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

const constants = {
  ORDER_STATUS: [
    { value: 1, label: '已支付' },
    { value: 2, label: '已完成' },
    { value: 3, label: '退货待审核' },
    { value: 4, label: '退货已完成' },
    { value: 5, label: '退货驳回' },
  ],
};

export const columns: BasicColumn[] = [
  {
    title: '订单号',
    dataIndex: 'orderId',
    width: 200,
  },
  {
    title: '权益订单号',
    dataIndex: 'unionOrderid',
    width: 200,
  },
  {
    title: '订单状态',
    dataIndex: 'status',
    width: 100,
    customRender: ({ record }) => {
      const status = record.status;
      // const enable = ~~status === 0;
      const text = constants.ORDER_STATUS.find((i) => i.value === status)?.label;
      return text;
    },
  },
  {
    title: '下单时间',
    dataIndex: 'createTime',
    width: 200,
  },
  {
    title: '收货人',
    dataIndex: 'contactName',
    width: 100,
  },
  {
    title: '收货手机',
    dataIndex: 'mobile',
    width: 200,
  },
  {
    dataIndex: 'address',
    title: '收货人地址',
    width: 260,
    customRender: ({ record }) => {
      return record.province + record.city + record.county + record.address;
    },
  },
  {
    title: '实付金额',
    dataIndex: 'money',
    width: 80,
  },
  {
    title: '驳回原因',
    dataIndex: 'rejectReason',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'orderId',
    label: '订单号',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'status',
    label: '订单状态',
    component: 'Select',
    componentProps: {
      options: constants.ORDER_STATUS,
    },
    colProps: { span: 6 },
  },
  {
    field: 'productNo',
    label: '商品编号',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: '[startTime, endTime]',
    label: '下单时间',
    component: 'RangePicker',
    componentProps: {
      format: 'YYYY-MM-DD HH:mm:ss',
      placeholder: ['开始时间', '结束时间'],
      showTime: { format: 'HH:mm:ss' },
    },
    colProps: { span: 12 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'orderId',
    label: '订单编号：',
    component: 'Input',
    // suffix: ({ values }) => values.orderId,
    dynamicDisabled: true,
    // valueField:'orderId',
    // slot: 'orderId',
    // defaultValue:'11111111111111111111111',
    colProps: {
      span: 24,
    },
  },
  // {
  //   field: 'unionOrderid',
  //   label: '权益订单编号：',
  //   component: 'Input',
  //   // suffix: ({ values }) => values.orderId,
  //   dynamicDisabled: true,
  //   // valueField:'orderId',
  //   // slot: 'orderId',
  //   // defaultValue:'11111111111111111111111',
  //   colProps: {
  //     span: 24,
  //   },
  // },
  {
    field: 'unionOrderid',
    label: '权益订单编号：',
    component: 'Input',
    show: false,
  },
  {
    field: 'status',
    label: ' ',
    component: 'RadioGroup',
    colProps: {
      span: 24,
    },
    required: true,
    componentProps: {
      options: [
        { label: '审核通过', value: 0 },
        { label: '驳回', value: 1 },
      ],
    },
  },
  {
    field: 'rejectReason',
    label: '驳回原因：',
    colProps: {
      span: 24,
    },
    ifShow: ({ values }) => values.status === 1,
    required: true,
    component: 'InputTextArea',
  },
];
